<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>词库管理系统</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<a href="<?php echo url('WordBankAdmin');?>" target="_self" class="Dig"><strong>HOME</strong></a>
<?
//require_once('datastruct.php');
//require_once('functions.php');

//$sql = "SELECT * FROM `word_bank`";

//用来获得分页数据，获取总数据条数，没有bind操作，很省时。
/*$mss = new MySQLSource($sql);
$itemsCount = $mss->getItemCount();
$itemsPerPage = 30;
$currentPage = $_GET['pageID'] ? $_GET['pageID'] : 1;
unset($mss);*/

//用来读取数据，bind涉及到数据复制
//$mss = new MySQLSource($sql." LIMIT ".$itemsPerPage * ($currentPage-1).",".$itemsPerPage);
//$ds = new DataSet;
//$ds->mssBind($mss); //这步耗时，所以只是获得记录数量的话，不需要dataset，参考getItemCount

//echo "<br>dataset中的原始数据:<br/>";
//echo "数据条数:" . $ds->itemCount . "<br/>";

/*$fieldNameArr = $mss->getFiledNameArr();
$filedCount = $mss->getFieldCount();

for($i=0;$i< $ds->itemCount;$i++) {
	for($j=0;$j < $filedCount;$j++) {
		echo $row[$fieldNameArr[$j]] . "  ";
	}
	echo "<br/>";
}*/

//还有一种增加用户的方法
/*
$mss1 = new MySQLSource("userinfo"); //这里仅仅需要表名
$ds1 = new DataSet;
$ds1->mssBind($mss1);
$ds1->dataSet[0]['staff_id'] = 911;  //注意这个是主键，不能相同才能正常插入
$ds1->dataSet[0]['nickname'] = "nickname";
$ds1->dataSet[0]['staff_name'] = "staff_name";
$ds1->dataSet[0]['report_to'] = "report to";
$ds1->dataSet[0]['score'] = 200;
$ds1->dataSet[0]['level'] = 50;
$ds1->dataSet[0]['lock'] = 0;
$ds1->mssAdd(1);
*/


//如果发现有POST数据，那么就先更新dataset，并提交到数据库
/*if(!empty($_POST))
{
    date_default_timezone_set('Asia/Chongqing');
	for($i=0;$i< $ds->itemCount;$i++)
	{
		$row['word'] = $_POST['word'.$row['id']];
		$row['type'] = $_POST['type'.$row['id']];
		$row['gender'] = $_POST['gender'.$row['id']];
		$row['score'] = $_POST['score'.$row['id']];
		$row['isgood'] = $_POST['isgood'.$row['id']];
		$row['lasttime'] = date("Y-m-d H:i:s");
	}
	$ds->mssUpdate();
}*/

//启用分页功能，$paging变量就是分页代码。见functions文件
//$pageing = pagingEnable($itemsPerPage,$itemsCount);

// 下面是print出格式化过的数据
$postUrl = url('ArtificialFilter', 'Index', array('page' => $PagerData['currentPage']));
print<<<eot
<br><br>
<!-- 注意这里pageID需要传送变量 -->
<!-- action后面指定这个表单将要提交的页面地址，设置为提交给自己 -->
<form id="form1" name="form1" method="post" action="{$postUrl}">
<table width="80%" border="0" align="center">
<tr>
<td width="10%" height="24" bgcolor="#DFDFDF">编号</td>
<td width="10%" bgcolor="#DFDFDF">词条</td>
<td width="10%" bgcolor="#DFDFDF">类型</td>
<td width="10%" bgcolor="#DFDFDF">词性</td>
<td width="10%" bgcolor="#DFDFDF">分数</td>
<td width="10%" bgcolor="#DFDFDF">是否录入</td>
<td width="20%" bgcolor="#DFDFDF">录入时间</td>
<td width="20%" bgcolor="#DFDFDF">最后修改时间</td>
</tr>
eot;
		foreach ($rowset as $row)
		{
			$extra = "";
			$check = "";
			if($row['isgood'])$check = "checked=\"checked\"";
print<<<eot
<tr>
<td height="24" bgcolor="#F3F3F3">{$row['id']}&nbsp;{$extra}</td>
<td height="24" bgcolor="#F3F3F3">
<label>
<input size="8" type="text" name="word{$row['id']}" value="{$row['word']}"/>
</label>
</td>
<td height="24" bgcolor="#F3F3F3">
<label>
<input size="8" type="text" name="type{$row['id']}" value="{$row['type']}"/>
</label>
</td>
<td height="24" bgcolor="#F3F3F3">
<label>
<input size="8" type="text" name="gender{$row['id']}" value="{$row['gender']}"/>
</label>
</td>
<td height="24" bgcolor="#F3F3F3">
<label>
<input size="8" type="text" name="score{$row['id']}" value="{$row['score']}"/>
</label>
</td>
<td height="24" bgcolor="#F3F3F3"><input type="checkbox" name="isgood{$row['id']}" value="1" {$check}/></td>
<td height="24" bgcolor="#F3F3F3">{$row['firsttime']}&nbsp;{$extra}</td>
<td height="24" bgcolor="#F3F3F3">{$row['lasttime']}&nbsp;{$extra}</td>
</tr>
eot;
}

print<<<eot
</table>
<table width="60%" height="100" border="0" align="center">
<tr>
<td align="center"><input type="reset" name="Reset" value="重置" />
&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit" name="Submit2" value="提交" /></td>
</tr>
<tr><td>
<div align="center" class="Page_area">
eot;
?>
<a href=<?php echo url('ArtificialFilter', 'index', array('page' => $PagerData['firstPage'])); ?> title='首页' class='Box_a'>&lt;&lt;</a>&nbsp;
<a href=<?php echo url('ArtificialFilter', 'index', array('page' => $PagerData['prevPage'])); ?> title='上一页' class='Box_a'>&lt;</a>&nbsp;
<?php
	foreach($NavbarIndexs as $temp)
	{
		if($temp['index'] != $PagerData['currentPage'])
			echo "<a href='".url('ArtificialFilter', 'index', array('page' => $temp['index']))."' title='' class='Box_a'>".$temp['number']."</a>&nbsp;";
		else
			echo "<span title='当前正在第".$temp['index']."页' class='Box_selected'>".$temp['number']."</span>&nbsp;";
	}
?>
<a href=<?php echo url('ArtificialFilter', 'index', array('page' => $PagerData['nextPage'])); ?> title='下一页' class='Box_a'>&gt;</a>&nbsp;
<a href=<?php echo url('ArtificialFilter', 'index', array('page' => $PagerData['lastPage'])); ?> title='末页' class='Box_a'>&gt;&gt;</a>&nbsp;
<?php
print<<<eot
</div>
</td></tr>
</table>
</form>
eot;
?>
</body>
</html>
